package cn.highedu.boot01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(Double height, Double weight) {
        double bmi = weight / (height * height);
        String message = "您的PMI指数为:" + bmi;
        if (bmi < 18.5) {
            message += " 兄弟你瘦了";
        }
        if (bmi >= 18.5 && bmi < 24) {
            message += " 恭喜, 身体很健康";
        }
        if (bmi >= 24 && bmi < 28) {
            message += " 兄弟有点胖";
        }
        if (bmi >= 28) {
            message += " 兄弟少吃点吧";
        }
        return message;
    }
}
